<template>
    <div>
        <p>
            <input type="text" placeholder="用户名" v-model="username">
        </p>
        <p>
            <input type="text" placeholder="密码" v-model="password">
        </p>
        <p><button @click="loginFn">登录</button></p>
    </div>
</template>

<script>
import axios from 'axios';
export default {
    data() {
        return {
            username: '',
            password: ''
        }
    },
    methods: {
        loginFn() {
            // 调用登录接口
            axios.post('http://kumanxuan1.f3322.net:8001/auth/loginByWeb', {
                username: this.username,
                pwd: this.password
            }).then(res => {
                // console.log('res', res);
                if (res.data.errno == 0) {
                    localStorage.setItem('token', res.data.data.token)
                }
                this.$router.push('/home')
            }).catch(err => { console.log(err); })
        }
    }
}
</script>
<style scoped></style>